//
// Created by 相开原 on 2022/3/23.
//

#ifndef I_SHOP_DATA_H
#define I_SHOP_DATA_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

#include "utility.h"
#include "typedef.h"
#include "account.h"

void init();

void checkPoint(char path_src[]);

// 🔽 =========== 以下为 fruit 部分 =========== 🔽

void read_fruitStored(char *path, fruit *head);

void read_fruitOnShelf(char *path, fruit *head);

void write_fruitStored(char *path_src);

void write_fruitOnShelf(char *path_src);

fruit *fruit_create();

void fruit_add(fruit *head, fruit item);

bool fruit_del(fruit *head, fruit *target);

void fruit_free(fruit *head);

// 🔽 =========== 以下为 purchaseMessage 部分 =========== 🔽

void read_purchaseMessage(char *path, purchaseMessage *head);

void write_purchaseMessage(char *path_src);

purchaseMessage *purchaseMessage_create();

void purchaseMessage_add(purchaseMessage *head, purchaseMessage item);

bool purchaseMessage_del(purchaseMessage *head, purchaseMessage *target);

void purchaseMessage_free(purchaseMessage *head);

// 🔽 =========== 以下为 sellMessage 部分 =========== 🔽

void read_sellMessage(char *path, sellMessage *head);

void write_sellMessage(char *path_src);

sellMessage *sellMessage_create();

void sellMessage_add(sellMessage *head, sellMessage item);

bool sellMessage_del(sellMessage *head, sellMessage *target);

void sellMessage_free(sellMessage *head);

// 🔽 =========== 以下为 account 部分 =========== 🔽

void write_account(char *path_src);

void read_account(char *path, account *head);

account *account_create();

void account_add(account *head, account item);

bool account_del(account *head, account *target);

void account_free(account *head);

// 🔽 =========== 以下为 shop 部分 =========== 🔽

void read_shop(char *path, struct shop_item *item);

void write_shopInfo(char *path_src);

// 🔽 =========== 以下为 pointer 部分 =========== 🔽

void pointer_swap(pointer *p1, pointer *p2);

void pointer_sort(pointer *head, bool descending);

pointer *pointer_create();

void pointer_add(pointer *head, void *item, int type, double data);

void pointer_del(pointer *head, pointer *item);

void pointer_free(pointer *head);

// 🔽 =========== 以下为 extern 部分 =========== 🔽
extern fruit *head_fruitStored;
extern fruit *head_fruitOnShelf;
extern purchaseMessage *head_purchaseMessage;
extern sellMessage *head_sellMessage;
extern account *head_user;
extern account *head_VIP;
extern struct shop_item shop;
extern account *current_user;
#endif //I_SHOP_DATA_H
